<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <title>树形菜单测试</title>
  <#include "/common/treelib.html">
</head>
<body>
<div style="width:200px;height:595px;border: 1px solid #e5e5e5;float:left;">
  <ul class="ztree" id="treeDemo"></ul>
</div>
<div style="width:1130px;height:100%;float:left;">
  <iframe id="iframepage" src="/demo/welcome"
          style="background: white;border: 0; width: 100%; height: 595px; padding: 0;"></iframe>
</div>
</body>
<script type="text/javascript">
    $(function () {
        var demoTreeId = $("#treeDemo");
        var treeName = "treeDemo";
        var TreeManager = {
            /**
             *初始化方法
             */
            init: function () {
                /**
                 * 设置zTree树
                 */
                var setting = {
                    data: {
                        simpleData: {
                            enable: true
                        }
                    },
                    callback: {
                        beforeClick: beforeClick,
                        onClick: onClick
                    }
                };

                function beforeClick(treeId, treeNode, clickFlag) {
                    return (treeNode.click != false);
                }

                function onClick(event, treeId, treeNode, clickFlag) {
                    alert(treeNode.id);
                }

                var nodesJson = "${nodesJson}";
                var zNodes = eval(nodesJson);
                $.fn.zTree.init(demoTreeId, setting, zNodes);//初始化树
            }
        };
        TreeManager.init();
    });
</script>
</html>
